#!/bin/bash
## master install

source ../config/hosts.conf
hostname $master_name
echo $master_name > /etc/hostname

cat << EOF >> /etc/hosts
$master_ip  $master_name
$node1_ip   $node1_name
$node2_ip   $node2_name
EOF




yum install python-rhsm* -y

# 安装master 组件
yum install -y etcd  flannel kubernetes-master kubernetes-client

#配置etcd
mv  /etc/etcd/etcd.conf  /etc/etcd/etcd.conf_bak
cp ../config/master_etcd.conf  /etc/etcd/etcd.conf
#启动ectd
systemctl enable etcd.service
systemctl  start etcd.service

#apiserver
mv /etc/kubernetes/apiserver  /etc/kubernetes/apiserver_bak
cp ../config/master_apiserver /etc/kubernetes/apiserver

mv /etc/kubernetes/config   /etc/kubernetes/config_bak
cp  ../config/master_config /etc/kubernetes/config


systemctl enable kube-apiserver.service
systemctl start kube-apiserver.service
systemctl enable kube-controller-manager.service
systemctl start kube-controller-manager.service
systemctl enable kube-scheduler.service
systemctl start kube-scheduler.service

#配置flannel
mv /etc/sysconfig/flanneld  /etc/sysconfig/flanneld_bak
cp ../config/flanneld /etc/sysconfig/flanneld

etcdctl mk /atomic.io/network/config '{ "Network": "172.16.0.0/16" }'

systemctl enable flanneld.service 
systemctl start flanneld.service 
systemctl restart kube-apiserver.service
systemctl restart kube-controller-manager.service
systemctl restart kube-scheduler.service


